home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / mcu11 / pcbugb.arc / TALKEREE.ASC < prev    next >
Text File  |  1990-04-03  |  7KB  |  191 lines

  1. *************************** TALKEREE.ASC 3/4/90 **************************
  2. *   Motorola Copyright 1988,1990                                         *
  3. *   MCU resident, Interrupt driven Communication routines for 68HC11     *
  4. *   monitor. Provides low level memory and stack read/write operations.  *
  5. *                                                                        *
  6. *   This talker DOES NOT uses XIRQ                                       *
  7. *   ------------------------------                                       *
  8. *                                                                        *
  9. * N.B. TALKEREE.ASC is designed to work with the 68HC11A1 or other       *
  10. *      compatible MCU types. This version of the TALKER is designed to   *
  11. *      execute from internal EEPROM located at $B600-$B7FF.              *
  12. *      TALKEREE must have been previously downloaded in some manner, for *
  13. *      instance using PCBUG11 BOOTA8 option, and EEPROM & LOADS commands.*
  14. *      To initiate communication with TALKEREE, an SCI break condition   *
  15. *      must be detected by the 68HC11 running in bootstrap mode.         *
  16. *      When PCBUG11 is executed with option TALKEREE, a 10mS break is    *
  17. *      output to the 68HC11's SCI, prior to establishing communication.  *
  18. *
  19. * CONSTANTS
  20. TALKBASE  equ $B600
  21. BOOTVECT  equ $00C4       Start of bootstrap vector jump table.
  22. STACK     equ $003F       User may alter this parameter if required
  23. REGBASE   equ $1000
  24. *
  25. JSCI      equ $00C4
  26. JXIRQ     equ $00F1
  27. JSWI      equ $00F4
  28. JILLOP    equ $00F7
  29. JCOP      equ $00FA
  30. JMPEXT    equ $7E         Mnemonic for jump extended instruction
  31. BRKCODE   equ $4A         Break point signal code to host.
  32. BRKACK    equ $4A         Break point acknowledge code from host.
  33. *
  34. * REGISTERS
  35. BAUD      equ $2B
  36. SCCR1     equ $2C
  37. SCCR2     equ $2D
  38. SCSR      equ $2E
  39. SCDR      equ $2F
  40. *
  41. RDRF      equ $20
  42. TDRE      equ $80
  43. OR        equ $08
  44. FE        equ $02
  45. *
  46. * PROGRAM
  47.           org TALKBASE
  48. TLKRSTART EQU *         First dynamically set up Boot vector jump table.
  49.           LDAA #JMPEXT
  50.           LDY #NULLSRV
  51.           LDX #BOOTVECT
  52. SETVECT   EQU *
  53.           STAA ,X
  54.           INX
  55.           STY ,X
  56.           INX
  57.           INX
  58.           CPX #$100
  59.           BNE SETVECT
  60.           LDX #SCISRV
  61.           STX JSCI+1
  62.           LDX #TLKRSTART
  63.           STX JILLOP+1
  64. *
  65. USERSTART EQU *
  66.           LDS #STACK
  67.           LDX #REGBASE
  68.           CLR SCCR1,X
  69.           LDD #$302C
  70.           STAA BAUD,X   Initialise SCI to 9600 baud, no parity, no interrupt
  71.           STAB SCCR2,X  and enable SCI tx & rx.
  72.           LDAA #$40     Enable STOP, and I bit interrupts, disable XIRQ.
  73.           TAP
  74. *
  75. IDLE      JMP IDLE      Now hang around for SCI interrupt from host.
  76. * A RESET from host changes above jump destination to start of user code.
  77. *
  78. SCISRV    EQU *             On detecting interrupt,
  79.           LDAA SCSR+REGBASE assume receiver caused it.
  80.           ANDA #RDRF
  81.           BEQ SCISRV        otherwise program will hang up
  82. *
  83. RXSRV     EQU *             Talker code processes received data.
  84.           LDAA SCDR+REGBASE Read command byte, & echo it as acknowledge
  85.           COMA              Inverted
  86.           BSR OUTSCI        to host.
  87.           BPL INH1      If command bit 7 set, then process inherent command
  88.           BSR INSCI     else read byte count from host into ACCB.(0=256)
  89.           XGDX          Save command and byte count.
  90.           BSR INSCI     Read high address byte
  91.           TBA           into ACCA
  92.           BSR INSCI     then low address byte into ACCB
  93.           XGDX          Restore command in ACCA,count in ACCB,address in X
  94.           CMPA #$FE
  95.           BNE RXSRV1    If command is memory read, then
  96. *
  97. TREADMEM  EQU *         REPEAT
  98.           LDAA ,X       read required address
  99.           BSR OUTSCI    send it to host
  100.           TBA           (save byte count)
  101.           BSR INSCI     and wait for acknowledge
  102.           TAB           (restore byte count)
  103.           INX           Increment address
  104.           DECB          Decrement byte count
  105.           BNE TREADMEM  UNTIL all done
  106.           RTI           and return to idle loop or user code.
  107. *
  108. RXSRV1    EQU *
  109.           CMPA #$BE
  110.           BNE RXSRVEX    If command is memory write then
  111. *
  112.           TBA           move byte count to ACCA
  113. TWRITMEM  EQU *         REPEAT
  114.           BSR INSCI     Read next byte from host into ACCB,
  115.           STAB ,X       and store at required address.
  116.           LDY #$0001    Set up wait loop to allow for 28C64 prog time, where
  117. WAITPOLL  DEY           Y operand must be manually set to $0359 (3mS)
  118.           BNE WAITPOLL
  119.           LDAB ,X       Read stored byte and
  120.           STAB SCDR+REGBASE   echo it back to host,
  121.           INX
  122.           DECA          Decrement byte count
  123.           BNE TWRITMEM  UNTIL all done
  124. RXSRVEX   EQU *         and return
  125. NULLSRV   RTI
  126. *
  127. INSCI     EQU *
  128.           LDAB SCSR+REGBASE   Wait for RDRF=1
  129.           BITB #(FE+OR)       If break detected then
  130.           BNE TLKRSTART       restart talker.
  131.           ANDB #RDRF
  132.           BEQ INSCI
  133.           LDAB SCDR+REGBASE   then read data received from host
  134.           RTS                 and return with data in ACCB
  135. *
  136. OUTSCI    EQU *               Only register Y modified.
  137.           XGDY                Enter with data to send in ACCA.
  138. OUTSCI1   LDAA SCSR+REGBASE
  139.           BPL OUTSCI1         MS bit is TDRE flag
  140.           XGDY
  141.           STAA SCDR+REGBASE   Important - Updates CCR!
  142.           RTS
  143. *
  144. INH1      EQU *
  145.           CMPA #$7E     If command is read MCU registers then
  146.           BNE INH2
  147. *
  148. INH1A     TSX           Move stack pointer to X
  149.           XGDX          then to ACCD
  150.           BSR OUTSCI    send stack pointer to host (high byte first)
  151.           TBA
  152.           BSR OUTSCI    then low byte
  153.           TSX           Restore X (=stack pointer)
  154.           LDAB #9       then return 9 bytes on stack
  155.           BRA TREADMEM  i.e. CCR,ACCB,ACCA,IXH,IXL,IYH,IYL,PCH,PCL
  156. *
  157. INH2      EQU *
  158.           CMPA #$3E     If command is write MCU registers then
  159.           BNE SWISRV1
  160. *
  161.           BSR INSCI     get stack pointer from host (High byte first)
  162.           TBA
  163.           BSR INSCI
  164.           XGDX          Move to X reg
  165.           TXS           and copy to stack pointer
  166.           LDAA #9       Then put next 9 bytes from host on to stack
  167.           BRA TWRITMEM
  168. *
  169. SWISRV    EQU *         Breakpoints generated by host-placed SWI instruction.
  170.           LDAA #BRKCODE Force host to process breakpoints
  171.           BSR OUTSCI    by sending it the break signal
  172. SWIIDLE   CLI
  173.           BRA SWIIDLE   then wait for response from host. (Ibit=0,Xbit=1)
  174. *
  175. SWISRV1   EQU *
  176.           CMPA #BRKACK  If host has acknowledged breakpoint state then
  177.           BNE RXSRVEX
  178.           TSX           move stack pointer to SWI stack frame and
  179.           LDAB #9
  180.           ABX
  181.           TXS
  182.           LDD 7,X       Send user code breakpoint return address to host
  183.           BSR OUTSCI    (high byte first)
  184.           TBA
  185.           BSR OUTSCI    (low byte next)
  186.           LDD #SWIIDLE  force idle loop on return from breakpoint processing
  187.           STD 7,X
  188.           BRA INH1A     but first return all MCU registers to host
  189. *
  190.           END
  191.